<?php require_once('../modulos/headerUsuario.php'); ?> 

            <body  style="background-image: url(../img/rayas_verticales.jpg); background-size: 100%;">
                
<?php require_once('../modulos/navbarUsuario.php'); ?>
                <div class="text-center" style="background: black;">
                        <h1 style="font-family: 'Tempus Sans ITC';  background: black;  color: #BC6D13; font-size: 50px; font-style: normal; padding-bottom: 10px; padding-top: 10px; border-radius: 9px;">ESTADISTICAS</h1>
                    
                </div>
                <div class='row'>
                    <div class="col-md-8  text-center col-lg-offset-2" >
                    <div class="col-md-12 text-center " style="padding-top: 5px; padding-bottom: 5px; color: white; font-size: 30px; font-style: normal; font-family: 'Tempus Sans ITC'; background-color: #3F3636; border: black; border-top-left-radius: 15px; border-top-right-radius: 15px">
                        
                      <a class=" text-center" style="padding-top: 0px; padding-bottom: 5px;  height: 50px; color: white; background-color: red" href="ver_jugadores.php">
                        <div class="col-md-4 text-center " style="height: 50px;font-size: 20px; border-right-style: solid; border-right-color: white; padding-top: 10px">
                            <strong>Volver a Jugadores</strong>
                        </div>
                      </a>
                        
                        <div class="col-md-8 text-center" style="padding-top: 5px">
                            Estadísticas del Jugador
                        </div>
                    </div>
                    <div class="col-md-12 text-center " style="background: #e7e7e7; border-bottom-left-radius: 15px; border-bottom-right-radius: 15px">
                        <?php
                            require_once '../conexUsuario.php';

                            if (isset($_GET['id'])){
                                $idPlayer = $_GET['id'];
                            }

                            $texto = "SELECT * FROM jugadores WHERE jugadores.idJugadores = $idPlayer";
                            $ej = mysql_query($texto);
                            $fila = mysql_fetch_array($ej);

                            $tempos="   SELECT idTemporada AS idTemp, periodo AS temp
                                        FROM temporadas";
                            $qr = mysql_query($tempos);
                        ?>
                        <br> 
                            <div class="col-md-12 text-center" style="height: 280px; background: #e7e7e7">
                                <div class="col-md-4 text-left" style=" "> 
                                    <?php   
                                        
                                        require_once ('../conexUsuario.php');

                                        $jugadors= "SELECT idJugadores ,nombre, apellido, posicion
                                                    FROM jugadores";

                                        $query = mysql_query($jugadors);
                                    ?>    
                                    
                                    <ul class="nav nav-sidebar" style=" max-height: 250px; overflow-y: scroll">
                                        <li class="dropdown-header text-left" style="background-color: #3F3636; color: white; border-top-left-radius: 5px; border-top-right-radius: 5px">Porteros</li>
                                        <?php 
                                        while ($arreglo = mysql_fetch_array($query)){ 
                                            if($arreglo['posicion'] == 'portero'){   ?>
                                                <li class=" text-center" style="height: 30px; margin-bottom: 2px; "><a style=";height: 30px;  color: black; font-family: 'Tempus Sans ITC'; font-size: 15px;" href="ver_estadisticaJugador.php?id=<?php echo $arreglo['idJugadores'];?>">
                                                      <?php echo $arreglo['nombre'].' '.$arreglo['apellido']; ?>
                                                    </a>
                                                </li>  
                                        <?php } 
                                        }?>
                                        <br>      
                                        <li class="dropdown-header text-left" style="background-color: #3F3636; color: white; border-top-left-radius: 5px; border-top-right-radius: 5px">Defensores</li>
                                        <?php 
                                        $query = mysql_query($jugadors);
                                        while ($arreglo = mysql_fetch_array($query)){ 
                                            if($arreglo['posicion'] == 'defensa'){   ?>
                                                <li class=" text-center" style="height: 30px; margin-bottom: 2px; "><a style=";height: 30px;  color: black; font-family: 'Tempus Sans ITC'; font-size: 15px; " href="ver_estadisticaJugador.php?id=<?php echo $arreglo['idJugadores'];?>">
                                                      <?php echo $arreglo['nombre'].' '.$arreglo['apellido']; ?>
                                                    </a>
                                                </li>  
                                        <?php } 
                                        }?>
                                        <br>         
                                        <li class="dropdown-header text-left" style="background-color: #3F3636; color: white; border-top-left-radius: 5px; border-top-right-radius: 5px">Mediocampistas</li>
                                        <?php 
                                        $query = mysql_query($jugadors);
                                        while ($arreglo = mysql_fetch_array($query)){ 
                                            if($arreglo['posicion'] == 'mediocampista'){   ?>
                                                <li class=" text-center" style="height: 30px; margin-bottom: 2px; "><a style=";height: 30px;  color: black; font-family: 'Tempus Sans ITC'; font-size: 15px; " href="ver_estadisticaJugador.php?id=<?php echo $arreglo['idJugadores'];?>">
                                                      <?php echo $arreglo['nombre'].' '.$arreglo['apellido']; ?>
                                                    </a>
                                                </li>  
                                        <?php } 
                                        }?>
                                        <br>         
                                        <li class="dropdown-header text-left" style="background-color: #3F3636; color: white; border-top-left-radius: 5px; border-top-right-radius: 5px">Delanteros</li>
                                        <?php 
                                        $query = mysql_query($jugadors);
                                        while ($arreglo = mysql_fetch_array($query)){ 
                                            if($arreglo['posicion'] == 'delantero'){   ?>
                                                <li class=" text-center" style="height: 30px; margin-bottom: 2px; "><a style=";height: 30px;  color: black; font-family: 'Tempus Sans ITC'; font-size: 15px;" href="ver_estadisticaJugador.php?id=<?php echo $arreglo['idJugadores'];?>">
                                                      <?php echo $arreglo['nombre'].' '.$arreglo['apellido']; ?>
                                                    </a>
                                                </li>  
                                        <?php } 
                                        }?>               
                                    </ul>
                                    
                                </div>
                                <div class="col-md-3 text-center"> 
                                    <img style="border-radius: 10%; width: 150px; height: 200px;" src='<?php echo '../img/'.$fila['imagen'];?>' />
                                </div>
                                <div class="col-md-5 text-left">
                                    <h3 class="text-center" style="background-color: #5F5353; color: white"><?php echo $fila['nombre'].' '.$fila['apellido'].'<br>'; ?></h3>
                                    <br>
                                    <label>Fecha de Nacimiento: <?php echo $fila['fecha_nacimiento']; ?></label>
                                    <br>
                                    <label>Lugar de Nacimiento: <?php echo $fila['lugarNacimiento']; ?></label>
                                    <br>
                                    <label>Peso: <?php echo $fila['peso']; ?></label>
                                    <br>
                                    <label>Estatura: <?php echo $fila['estatura']; ?></label>
                                    <br>
                                    <label>Posición preferida: <?php echo $fila['posicion']; ?></label>
                                </div>
                            </div>
                        <br>
                        <br>
                            <div class=" text-left  " style="background-color: #5F5353; padding: 5px; color: white">
                                TODAS LAS COMPETICIONES
                            </div>
                            <table id="tablita" class="table">
                                    <thead>
                                        <tr style="background-color: rgba(86,61,124,.15);">
                                            <th class="text-center">Temporada</th>
                                            <th class="text-center">Partidos</th>
                                            <th class="text-center">Goles</th>
                                            <th class="text-center">Faltas</th>
                                            <th class="text-center">Tar. Amarillas</th>
                                            <th class="text-center">Tar. Rojas</th>
                                            <th class="text-center">Autogoles</th>
                                            <th class="text-center">Lesiones</th>
                                            <?php  if($fila['posicion'] == 'portero'){ ?>
                                                <th class="text-center">Paradas</th>        
                                            <?php  }else{ ?>
                                                <th class="text-center">Tiros</th>
                                                <th class="text-center">Tiros Puerta</th>
                                            <?php  } ?>
                                        </tr>
                                    </thead>
                                <tbody style="background-color: #f9f9f9;"> 
                                    
                                 <?php  while ($arreglo = mysql_fetch_array($qr)){   
                                            $tem = $arreglo['temp'];
                                     ?>
                                    <tr>
                                        <th class="text-center">
                                            <?php echo $tem; ?>
                                        </th>
                                        <th class="text-center">
                                            <?php
                                                
                                            ?>
                                        </th>
                                        <th class="text-center">
                                            <?php
                                                $GL = " SELECT cantidadEventos(".$idPlayer.",'$tem','gol_favor') AS Total";
                                                $q = mysql_query($GL);
                                                $arr = mysql_fetch_array($q);
                                                echo $arr['Total'];        
                                            ?>
                                        </th>
                                        <th class="text-center">
                                            <?php
                                                $FL = " SELECT cantidadEventos(".$idPlayer.",'$tem','falta') AS Total";
                                                $q2 = mysql_query($FL);
                                                $arr1 = mysql_fetch_array($q2);
                                                echo $arr1['Total'];        
                                            ?>
                                        </th>
                                        <th class="text-center">
                                            <?php
                                                $TA = " SELECT cantidadEventos(".$idPlayer.",'$tem','tarjeta_amarilla') AS Total";
                                                $q3 = mysql_query($TA);
                                                $arr2 = mysql_fetch_array($q3);
                                                echo $arr2['Total'];        
                                            ?>
                                        </th>
                                        <th class="text-center">
                                            <?php
                                                $TR = " SELECT cantidadEventos(".$idPlayer.",'$tem','tarjeta_roja') AS Total";
                                                $q4 = mysql_query($TR);
                                                $arr3 = mysql_fetch_array($q4);
                                                echo $arr3['Total'];        
                                            ?>
                                        </th>
                                        <th class="text-center">
                                            <?php
                                                $AG = " SELECT cantidadEventos(".$idPlayer.",'$tem','autogol') AS Total";
                                                $q5 = mysql_query($AG);
                                                $arr4 = mysql_fetch_array($q5);
                                                echo $arr4['Total'];        
                                            ?>
                                        </th>
                                        <th class="text-center">
                                            <?php
                                                $LES = " SELECT cantidadEventos(".$idPlayer.",'$tem','lesion') AS Total";
                                                $q6 = mysql_query($LES);
                                                $arr5 = mysql_fetch_array($q6);
                                                echo $arr5['Total'];        
                                            ?>
                                        </th>
                                        <?php  if($fila['posicion'] == 'portero'){ ?>
                                            <th class="text-center">
                                                <?php
                                                    $PAR = " SELECT cantidadEventos(".$idPlayer.",'$tem','parada') AS Total";
                                                    $q7 = mysql_query($PAR);
                                                    $arr6 = mysql_fetch_array($q7);
                                                    echo $arr6['Total'];        
                                                ?>
                                            </th>
                                        <?php }else{ ?>
                                            <th class="text-center">
                                                <?php
                                                    $TIR = " SELECT cantidadEventos(".$idPlayer.",'$tem','tiro') AS Total";
                                                    $q8 = mysql_query($TIR);
                                                    $arr7 = mysql_fetch_array($q8);
                                                    echo $arr7['Total'];        
                                                ?>
                                            </th>
                                            <th class="text-center">
                                                <?php
                                                    $TIRP = " SELECT cantidadEventos(".$idPlayer.",'$tem','tiro_puerta') AS Total";
                                                    $q9 = mysql_query($TIRP);
                                                    $arr8 = mysql_fetch_array($q9);
                                                    echo $arr8['Total'];        
                                                ?>
                                            </th>
                                        <?php } ?>    
                                    </tr>
                                    <?php }?>   
                                </tbody>
                            </table>  
                        
                        
                            <?php 
                                $comps= "SELECT idCompeticiones as id,descripcion as comp
                                         FROM competiciones";
                                $tempords="   SELECT idTemporada AS idTemp, periodo AS temp
                                        FROM temporadas";
                                $con = mysql_query($comps);
                                while ($comp = mysql_fetch_array($con)){
                                    $qrry = mysql_query($tempords);
                            ?>
                            <br><br>
                            <div class=" text-left  " style="background-color: #5F5353; padding: 5px; color: white">
                                <?php echo $comp['comp']; ?>
                            </div>
                            <table id="tablita" class="table">
                                    <thead>
                                        <tr style="background-color: rgba(86,61,124,.15);">
                                            <th class="text-center">Temporada</th>
                                            <th class="text-center">Partidos</th>
                                            <th class="text-center">Goles</th>
                                            <th class="text-center">Faltas</th>
                                            <th class="text-center">Tar. Amarillas</th>
                                            <th class="text-center">Tar. Rojas</th>
                                            <th class="text-center">Autogoles</th>
                                            <th class="text-center">Lesiones</th>
                                            <?php  if($fila['posicion'] == 'portero'){ ?>
                                                <th class="text-center">Paradas</th>        
                                            <?php  }else{ ?>
                                                <th class="text-center">Tiros</th>
                                                <th class="text-center">Tiros Puerta</th>
                                            <?php  } ?>
                                        </tr>
                                    </thead>
                                <tbody style="background-color: #f9f9f9;"> 
                                    
                                 <?php  while ($arregloTem = mysql_fetch_array($qrry)){   
                                            $tem = $arregloTem['temp'];
                                     ?>
                                    <tr>
                                        <th class="text-center">
                                            <?php echo $tem; ?>
                                        </th>
                                        <th class="text-center">
                                            <?php
                                                
                                            ?>
                                        </th>
                                        <th class="text-center">
                                            <?php
                                                $GL = " SELECT cantidadEventosCompeticion(".$idPlayer.",'$tem','gol_favor',".$comp['id'].") AS Total";
                                                $q = mysql_query($GL);
                                                $arr = mysql_fetch_array($q);
                                                echo $arr['Total'];        
                                            ?>
                                        </th>
                                        <th class="text-center">
                                            <?php
                                                $FL = " SELECT cantidadEventosCompeticion(".$idPlayer.",'$tem','falta',".$comp['id'].") AS Total";
                                                $q2 = mysql_query($FL);
                                                $arr1 = mysql_fetch_array($q2);
                                                echo $arr1['Total'];        
                                            ?>
                                        </th>
                                        <th class="text-center">
                                            <?php
                                                $TA = " SELECT cantidadEventosCompeticion(".$idPlayer.",'$tem','tarjeta_amarilla',".$comp['id'].") AS Total";
                                                $q3 = mysql_query($TA);
                                                $arr2 = mysql_fetch_array($q3);
                                                echo $arr2['Total'];        
                                            ?>
                                        </th>
                                        <th class="text-center">
                                            <?php
                                                $TR = " SELECT cantidadEventosCompeticion(".$idPlayer.",'$tem','tarjeta_roja',".$comp['id'].") AS Total";
                                                $q4 = mysql_query($TR);
                                                $arr3 = mysql_fetch_array($q4);
                                                echo $arr3['Total'];        
                                            ?>
                                        </th>
                                        <th class="text-center">
                                            <?php
                                                $AG = " SELECT cantidadEventosCompeticion(".$idPlayer.",'$tem','autogol',".$comp['id'].") AS Total";
                                                $q5 = mysql_query($AG);
                                                $arr4 = mysql_fetch_array($q5);
                                                echo $arr4['Total'];        
                                            ?>
                                        </th>
                                        <th class="text-center">
                                            <?php
                                                $LES = " SELECT cantidadEventosCompeticion(".$idPlayer.",'$tem','lesion',".$comp['id'].") AS Total";
                                                $q6 = mysql_query($LES);
                                                $arr5 = mysql_fetch_array($q6);
                                                echo $arr5['Total'];        
                                            ?>
                                        </th>
                                        <?php  if($fila['posicion'] == 'portero'){ ?>
                                            <th class="text-center">
                                                <?php
                                                    $PAR = " SELECT cantidadEventosCompeticion(".$idPlayer.",'$tem','parada',".$comp['id'].") AS Total";
                                                    $q7 = mysql_query($PAR);
                                                    $arr6 = mysql_fetch_array($q7);
                                                    echo $arr6['Total'];        
                                                ?>
                                            </th>
                                        <?php }else{ ?>
                                            <th class="text-center">
                                                <?php
                                                    $TIR = " SELECT cantidadEventosCompeticion(".$idPlayer.",'$tem','tiro',".$comp['id'].") AS Total";
                                                    $q8 = mysql_query($TIR);
                                                    $arr7 = mysql_fetch_array($q8);
                                                    echo $arr7['Total'];        
                                                ?>
                                            </th>
                                            <th class="text-center">
                                                <?php
                                                    $TIRP = " SELECT cantidadEventosCompeticion(".$idPlayer.",'$tem','tiro_puerta',".$comp['id'].") AS Total";
                                                    $q9 = mysql_query($TIRP);
                                                    $arr8 = mysql_fetch_array($q9);
                                                    echo $arr8['Total'];        
                                                ?>
                                            </th>
                                        <?php } ?>    
                                    </tr>
                                    <?php }   ?>   
                                </tbody>
                            </table>
                        
                            <?php }  mysql_close()  ?>
                    </div> 
                </div>  
            </div> 
        
        <script type="text/javascript">
            function mostrarDetalle(id, total){
                var i;
                var fila;
                var tabla = document.getElementById("tablita");
                var div = document.getElementById("datos_player");
                
                for (i=0; i<total; i++){
                    if (id != i){
                        fila = document.getElementById("player"+i);
                        fila.style.display = "none";
                    }    
                } 
                
                tabla.style.display = "block";
                div.style.display = "block";
            }            
        </script>
    </body>
    <?php require_once('../modulos/footer.php'); ?>
</html>